package unq.uis.robots.ui;

import org.uqbar.arena.actions.MessageSend;
import org.uqbar.arena.widgets.Button;
import org.uqbar.arena.widgets.Label;
import org.uqbar.arena.widgets.Panel;
import org.uqbar.arena.widgets.TextBox;
import org.uqbar.arena.widgets.TextFilter;
import org.uqbar.arena.windows.Dialog;
import org.uqbar.arena.windows.WindowOwner;

import unq.uis.robots.applicationsModels.RobotVista;


public class RepararRobotWindow extends Dialog<RobotVista> {


	public RepararRobotWindow(WindowOwner owner, RobotVista model) {
		super(owner, model);
	}

	private static final long serialVersionUID = 1L;

	@Override
	protected void createFormPanel(Panel mainPanel) {
		this.setTitle("Reparar");		
		
		new Label(mainPanel).setText("Daño de robot");		
		new Label(mainPanel).setText(this.getModelObject().getDanio() + "%");
		
		new Label(mainPanel).setText("Daño a reparar");
		TextBox danioAReparar = new TextBox(mainPanel);
		danioAReparar.bindValueToProperty(RobotVista.DANIOAREPARAR);
		danioAReparar.withFilter(TextFilter.NUMERIC_TEXT_FILTER);			
		
		new Label(mainPanel).setText("Costo");
		Label costo = new Label(mainPanel);
		costo.bindValueToProperty(RobotVista.COSTODEREPARACION);
	}

	@Override
	protected void addActions(Panel actions) {
		new Button(actions)
			.setCaption("Aceptar")
			.onClick(new MessageSend(this, "accept"))
			.setAsDefault()
			.disableOnError();

		new Button(actions)
			.setCaption("Cancelar")
			.onClick(new MessageSend(this, "cancel"));
	}

}
